import http from '@/utils/request'

export interface DataItem {
  realName: string;
  userName: string;
  token: string;
  tokenDate: string;
}
export function getToken(): Promise<{ message: DataItem[] }> {
  return http.get('/get-token')
}

export function getDetailByUserName(userName: string): Promise<{ message: DataItem }> {
  return http.get(`/get-detail-by-username?userName=${userName}`)
}


export function setToken(data: DataItem) {
  return http.post('/add-token', data)
}

export function deleteToken(userName: string) {
  return http.get(`/delete-token?userName=${userName}`)
}



export function runJobAll(): Promise<{ message: string }> {
  return http.get('/run-job-all', {
    timeout: 0, // 禁用超时
  });
}



export function runJob(userName: string): Promise<{ message: string }> {
  return http.get(`/run-job?userName=${userName}`, {
    timeout: 0, // 禁用超时
  })
}

export function getObjectsByUsername(userName: string): Promise<{ message: any[] }> {
  return http.get(`/get-objects-by-username?userName=${userName}`)
}


export function runJobView(articleId: number): Promise<{ message: string }> {
  return http.get(`/read-article-by-id?articleId=${articleId}`, {
    timeout: 0, // 禁用超时
  });
}

export function runJobLike(articleId: number): Promise<{ message: string }> {
  return http.get(`/like-article-by-id?articleId=${articleId}`, {
    timeout: 0, // 禁用超时
  });
}

export function runJobCollect(articleId: number): Promise<{ message: string }> {
  return http.get(`/collect-article-by-id?articleId=${articleId}`, {
    timeout: 0, // 禁用超时
  });
}



export function runJobViewSingle(userName: string, articleId: number): Promise<{ message: string }> {
  return http.get(`/read-article-by-username?userName=${userName}&articleId=${articleId}`, {
    timeout: 0, // 禁用超时
  });
}

export function runJobLikeSingle(userName: string, articleId: number): Promise<{ message: string }> {
  return http.get(`/like-article-by-username?userName=${userName}&articleId=${articleId}`, {
    timeout: 0, // 禁用超时
  });
}

export function runJobCollectSingle(userName: string, articleId: number): Promise<{ message: string }> {
  return http.get(`/collect-article-by-username?userName=${userName}&articleId=${articleId}`, {
    timeout: 0, // 禁用超时
  });
}
